<?php
namespace app\validate;

use exception\ErrorException;
use think\Validate;
use const support\PARAMETER_ERROR;

class BaseValidate extends Validate
{

    /**
     * 验证校验
     * @param $scene '场景ID'
     * @param $data '数据'
     * @return bool
     * @throws ErrorException
     */
    public static function toCheck($scene, $data): bool
    {
        $validate = new static();
        if (!$validate->scene($scene)->check($data)) {
            throw new ErrorException((string)$validate->getError(),PARAMETER_ERROR);
        }
        return true;
    }

}